Fix flaky tests by making school teacher ID lookup deterministic#706
Fix flaky tests by making school teacher ID lookup deterministic#706zetter-rpf merged 1 commit intomainfrom
Conversation
|
Cursor Agent can help with this pull request. Just |
Test coverage89.92% line coverage reported by SimpleCov. |
df97f98 to
d1cffd4
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes the teacher ID lookup used by SchoolTeacher::List deterministic to eliminate intermittent test failures caused by non-deterministic role ordering.
Changes:
- Order teacher
Rolerecords byidbefore pluckinguser_ids whenteacher_idsaren’t provided.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mwtrew
left a comment
There was a problem hiding this comment.
Is it safe to get rid of the [...]&.[...]? I'm not sure if a school can have no teachers, though.
Yes, the query isn't executed until |
Example failure - https://github.com/RaspberryPiFoundation/editor-api/actions/runs/22571941511/job/65381726124 This was making the order that teaches returned non-deterministic, which was causing intermittent test failures. The test that was failing was the 'SchoolTeacher::List when successful when not passing teacher_ids returns a successful response with school teachers' test in ./spec/concepts/school_teacher/list_spec.rb. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
d1cffd4 to
b2f4f26
Compare
Example failure - https://github.com/RaspberryPiFoundation/editor-api/actions/runs/22571941511/job/65381726124
This was making the order that teaches returned non-deterministic, which was causing intermittent test failures.
The test that was failing was the 'SchoolTeacher::List when successful when not passing teacher_ids returns a successful response with school teachers' test in ./spec/concepts/school_teacher/list_spec.rb.